#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPushButton>
#include <QAction>
#include <QDialog>
#include <QMessageBox>
#include <QToolButton>
#include "model.h"

int model=0;


MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->menu_2->setIcon(QIcon(":/test/image/maxiu.JPG"));
    //setWindowIcon(QIcon(":/test/image/maxiu.JPG"));
    //setFixedSize(800,600);
    setWindowTitle(QString("小学生速算练习软件"));
    setFixedSize(674,406);



    connect(ui->actionq,&QAction::triggered,this,[=](){
        if(QMessageBox::Ok==QMessageBox::question(this,"退出","您确认要退出吗？",QMessageBox::Ok|QMessageBox::Cancel))
        {
            this->close();
        }
    });
    connect(ui->actionthanks,&QAction::triggered,this,[=](){
        QDialog *dial1 = new QDialog(this);
        dial1->resize(400,200);
        dial1->setWindowTitle("开发人员列表");
        dial1->setAttribute(Qt::WA_DeleteOnClose);
        dial1->show();
    });
    connect(ui->actionproperty,&QAction::triggered,this,[=](){
        QDialog *dial1 = new QDialog(this);
        dial1->resize(400,200);
        dial1->setWindowTitle("知识产权声明");
        dial1->setAttribute(Qt::WA_DeleteOnClose);
        dial1->show();
    });
    connect(ui->actionfunding,&QAction::triggered,this,[=](){
        QDialog *dial1 = new QDialog(this);
        dial1->resize(400,200);
        dial1->setWindowTitle("支付宝二维码");
        dial1->setAttribute(Qt::WA_DeleteOnClose);
        dial1->show();
    });

    //打开年纪选择模式
    //model为考试与测试模式选择指示标志，model=1为打开训练模式，model=2为打开考试模块
    connect(ui->ModExeBtn,&QToolButton::clicked,this,[=](){
        model=1;
        Model *m = new Model();
        m->show();
        m->setAttribute(Qt::WA_DeleteOnClose);
    });
    connect(ui->ModTesBtn,&QToolButton::clicked,this,[=](){
        model=2;
        Model *m = new Model();
        m->show();
        m->setAttribute(Qt::WA_DeleteOnClose);
    });

}

MainWindow::~MainWindow()
{
    delete ui;
}

